/*************************************************************************
	> File Name: P1455.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-04-02 17:01:41
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 10000
int c[MAX_N + 5], d[MAX_N + 5];
int dp[MAX_N + 5], father[MAX_N + 5];

int get_father(int x) {
    if (father[x] == x) return x;
    father[x] = get_father(father[x]); // 路径压缩
    return father[x];
}

void merge(int x, int y) {
    int fa = get_father(x);
    int fb = get_father(y);
    if (fa != fb) {
        c[fa] += c[fb];
        d[fa] += d[fb];
        father[fb] = fa;
        c[fb] = 0;
        d[fb] = 0;
    }
    return ;
}

int main() {
    int n, m, w;
    cin >> n >> m >> w;
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &c[i], &d[i]);
        father[i] = i;
    }
    for (int i = 1, a, b; i <= m; i++) {
        scanf("%d%d", &a, &b);
        merge(a, b);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = w; j >= c[i]; j--) {
            dp[j] = max(dp[j], dp[j - c[i]] + d[i]);
        }
    }
    cout << dp[w] << endl;
    return 0;
}
